//题目:
// 请设计一个函数判断一棵二叉树是否 轴对称 。
#include<iostream>
#include<queue>
#include<unordered_map>
#include<string.h>
#include<algorithm>

using namespace std;
//代码:
struct TreeNode 
{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
class Solution 
{
public:
    bool checkSymmetricTree(TreeNode* root) 
    {
        if(root==nullptr)return true;

        queue<TreeNode*> q;
        q.push(root),q.push(root);
        while(!q.empty())
        {
            TreeNode* node1=q.front();q.pop();
            TreeNode* node2=q.front();q.pop();
            if(node1==nullptr && node2==nullptr)continue;
            if((node1==nullptr || node2==nullptr) || node1->val!=node2->val)return false;
            q.push(node1->left);
            q.push(node2->right);

            q.push(node1->right);
            q.push(node2->left);
        }
        return true;
    }
};